import { ApiCall } from "tsrpc";
import { ReqJoinWord_mingame, ResJoinWord_mingame } from "../../../../shared/master/bag/function/PtlJoinWord_mingame";
import { player } from "../../../../model/fight/body/player";
import { template } from "../../../../shared/master/MsgAction";
import manage_word from "../../../model/manage/manage_word";

export default async function (call: ApiCall<ReqJoinWord_mingame, ResJoinWord_mingame>) {
    call.succ({})
    if (call.req.num <= 0) {
        call.req.num = 1;
    }
    let user = call.req._player as player;
    let res = user.check_wallet(0, 0, [{ id: 'prop-23', v: call.req.num }], false, '澳门通行证', true);
    if (!res.state) {
        return;
    }
    let _res = await manage_word.transfer(user,'mingame')
    await user.sendMsg(template.default, _res.msg);
    user.callApi('word/Position', {})
}